﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp10
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;
            var repwd = textBox3.Text;

            var Uid = !string.IsNullOrEmpty(uid);
            var Pwd = !string.IsNullOrEmpty(pwd);
            var eqPwd = pwd == repwd;

            if(Uid&&Pwd&&eqPwd)
            {
                MessageBox.Show("注册成功", "提示");
                var sql = string.Format("insert into Users (Username,Password) values ('{0}','{1}')", textBox1.Text, textBox2.Text);
                var res = DbHelper.AddOrUpdateOrDelete(sql);

                this.Hide();
            }
            else
            {
                MessageBox.Show("注册失败", "提示");
            }
        }
    }
}
